from pathlib import Path

def mult_file_count_words(filename):
    """计算多文件大约包含多少个单词"""
    try:
        contents = path.read_text(encoding='utf-8')
    except FileNotFoundError:
        print(f"Sorry,the file {path} doesn't exist.")
        #pass 出现异常时什么也不会发生
    else:
        words = contents.split()
        num_words = len(words)
        print(f"The file {path} has about {num_words} words.")

filenames = ['day16/alice.txt','day16/siddhartha.txt','day16/moby_dick.txt',
            'day16/little_women.txt']

for filename in filenames:
    path = Path(filename)
    mult_file_count_words(path)